<case value="pictures">
    <div id="[type]{$group_k}_upload_{$[type]k}" {$[type]form.extra_attr}></div>
    <div id="[type]{$group_k}_preview_{$[type]k}">
        <input type="hidden" name="{$[type]form.name}" value="{$[type]form.value}">
        <notempty name="[type]form.value">
            <?php $images = explode(',',$[type]form['value']); ?>
            <foreach name="images" item="img">
                <span class="img-box"><img class="img" src="{$img|get_cover}" data-id="{$img}"><i class="fa fa-times-circle remove-picture"></i></span>
            </foreach>
        </notempty>
    </div>
    <script type="text/javascript">
        $(function(){
            $('#[type]{$group_k}_upload_{$[type]k}').Huploadify({
                uploader:'{:U(C("MODULE_MARK")."/PublicUpload/upload")}',
                fileTypeExts:'*.gif;*.jpg;*.jpeg;*.png;*.bmp',
                fileSizeLimit:{:C('UPLOAD_IMAGE_SIZE')}*1024,
                buttonText:'上传图片',
                onUploadComplete:function(file, data){
                    var data = $.parseJSON(data);
                    if(data.error == 1){
                        $.alertMessager(data.message, 'danger');
                    }else{
                        var input = $('#[type]{$group_k}_preview_{$[type]k} input');
                        var new_img = '<span class="img-box"><img class="img" src="' + data.url + '" data-id="'+data.id+'"><i class="fa fa-times-circle remove-picture"></i></span>';
                        $('#[type]{$group_k}_preview_{$[type]k}').append(new_img);
                        if(input.val()){
                            input.val(input.val() + ',' + data.id);
                        }else{
                            input.val(data.id);
                        }
                    }
                }
            });
            //删除图片
            $('#[type]{$group_k}_preview_{$[type]k} .remove-picture').click(function(){
                var ready_for_remove_id = $(this).closest('.img-box').find('img').attr('data-id'); //获取待删除的图片ID
                if(!ready_for_remove_id){
                    $.alertMessager('错误', 'danger');
                }
                var current_picture_ids = $('#[type]{$group_k}_preview_{$[type]k} input').val().split(","); //获取当前图集以逗号分隔的ID并转换成数组
                current_picture_ids.remove(ready_for_remove_id); //从数组中删除待删除的图片ID
                $('#[type]{$group_k}_preview_{$[type]k} input').val(current_picture_ids.join(',')) //删除后覆盖原input的值
                $(this).closest('.img-box').remove(); //删除图片预览图
            });
        });
    </script>
</case>